<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

if (!defined('DBC') || !defined('DBC_PMS_NEW'))
	exit;

define('DBC_PMS_LOADED', 1);

if (defined('DBC_PMS_NEW_CONFIRM'))
{
	if (!isset($_POST['delete']) && !isset($_POST['save']))
		message($lang_common['Bad request']);

	if (isset($_POST['delete']))
		$mflag = 2;
	else
		$mflag = 3;

	if (isset($_POST['action2']))
	{
		if (!isset($_POST['topics']))
			message($lang_common['Bad request']);

		if (@preg_match('/[^0-9,]/', $_POST['topics']))
			message($lang_common['Bad request']);

		$topics = explode(',', $_POST['topics']);
	}
	else
	{
		if (!isset($_POST['post_topic']))
			message($lang_common['Bad request']);

		$topics = array_map('intval', array_keys($_POST['post_topic']));
	}

	$kolvo = count($topics);
  
	if ($kolvo == 0)
		message($lang_pmsn['No dialogs']);
	if (count(array_diff($topics, $pmsn_arr_list)) > 0)
		message($lang_pmsn['Err1']);
	if ($mflag == 3 && $DBC_user['g_pm_limit'] != 0 && $pmsn_kol_save+$kolvo > $DBC_user['g_pm_limit'])
		message($lang_pmsn['Err2']);

	// действуем
	if (isset($_POST['action2']))
	{
		pmsn_user_delete($DBC_user['id'], $mflag, $topics);

		$mred = '';
		if (isset($_POST['p']))
		{
			$p = intval($_POST['p']);
			if ($p > 1)
				$mred = '&amp;p='.$p;
		}
		redirect('pmsnew.php?mdl=list'.$mred.$sidamp, $lang_pmsn['List redirect']);
	}
}
else
	message($lang_common['Bad referrer']);

if (isset($_POST['delete']))
{
	$mh2 = $lang_pmsn['InfoDeleteQ'];
	$mhm = $lang_pmsn['InfoDeleteQm'];
	$mfm = 'delete';
}
else
{
	$mh2 = $lang_pmsn['InfoSaveQ'];
	$mhm = $lang_pmsn['InfoSaveQm'];
	$mfm = 'save';
}

define('DBC_ACTIVE_PAGE', 'pms_new');
require DBC_ROOT.'engine/engine.php';
?>

<?php

generate_pmsn_menu($pmsn_modul);

?>
	<div class="blockform">


		<div class="pagepost_pm">
			<span class="contacts"><a href="index.php"><?php echo $lang_common['Index'] ?></a>
			<span>»&#160;</span><a href="pmsnew.php"><?php echo $lang_pmsn['PM'] ?></a>
			<span>»&#160;</span><?php echo $lang_pmsn[$pmsn_modul].($sid ? $lang_pmsn['With'].$siduser : '') ?>
		</div>
		<div class="clearer"></div>





	<table width="100%" height="38" border="0" cellpadding="0" cellspacing="0"><thead><tr>
	<td align="left" width="28" class="bg_forum_title_left"><img src="engine/skins/images/spacer.gif" border="0"></td>
	<td align="left" class="bg_forum_title_center"><span class="cat_title"><?php echo $mh2 ?></span></td>
	<td align="center" width="28" class="bg_forum_title_right"><img src="engine/skins/images/spacer.gif" border="0"></td>
	</tr></table>
	
	<table class="forum_adv_table"  width="100%" border="0" cellpadding="0" cellspacing="0"><thead><tr>
	<td align="left" class="forum_adv_tleft" width="2"><img src="engine/skins/images/spacer.gif" border="0"></td>
	<td align="left" width="100%"><div class="forum_adv2">








			<form method="post" action="pmsnew.php?mdl=listq<?php echo $sidamp ?>">
				<div class="inform">
					<input type="hidden" name="csrf_hash" value="<?php echo $pmsn_csrf_hash ?>" />
					<input type="hidden" name="topics" value="<?php echo implode(',', $topics) ?>" />
					<input type="hidden" name="<?php echo $mfm ?>" value="1" />
					<input type="hidden" name="p" value="<?php echo intval($_POST['p']) ?>" />
					<fieldset>
						<legend><?php echo $lang_pmsn['Attention'] ?></legend>
						<div class="infldset">
							<p><?php echo $mhm ?></p>
						</div>
					</fieldset>
				<p class="buttons"><input type="submit" class="fbutton" name="action2" value="<?php echo $lang_pmsn['Yes'] ?>" /></p>
				</div>
			</form>






<br/>
</div></td>
<td align="left" class="forum_adv_tright" width="2"><img src="engine/skins/images/spacer.gif" border="0"></td>
</td></tr></table>
<table width="100%" height="23" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="30" class="bg_forum_bott_left"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="left" class="bg_forum_bott_center"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="center" width="30" class="bg_forum_bott_right"><img src="engine/skins/images/spacer.gif" border="0"></td>
</tr></thead></table>





	</div>
<?php

